# -*- coding:utf-8 -*-
class Solution:
    # array 二维列表
    def Find(self, target, array):
        # write code here
        # height = array.shape[0]
        # width = array.shape[1]
        height = len(array)
        width = len(array)
        i = height-1
        j = 0
        while i>=0:
            if target > array[i][j]:
                j = width//2
                while j!=0:
                    if target > array[i][j-1]:
                        j += j//2
                    if target < array[i][j-1]:
                        j -= j//2
                    else:
                        return(True)
            if target < array[i][j]:
                i -= 1
            if target == array[i][j]:
                return(True)
            else:
                return(False)


a = [[1,2,3,4,5],
    [6,7,8,9,10],
    [11,12,13,14,15],
    [16,17,18,20,22]]
s = Solution()
print(s.Find(19,a))
